package isec.amov.tp2.automaintenance;

import android.os.Bundle;
import android.app.ListActivity;
import android.database.Cursor;
import android.view.Menu;
import android.widget.ListAdapter;
import android.widget.SimpleCursorAdapter;

public class VerCarro extends ListActivity {
	ListAdapter adapter;
	DBAdapter datasource;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_listar_carros);
		datasource = new DBAdapter(this);
		datasource.open();
		Cursor cursor = datasource.getCarros();
		String[] columns = new String[] {"marca", "modelo", "matricula", "quilometros"};
		int[] to = new int[] {R.id.txMarca, R.id.txModelo, R.id.txMatricula, R.id.txQuilometros};
		adapter = new SimpleCursorAdapter(this, R.layout.activity_ver_carro, cursor, columns, to);
		this.setListAdapter(adapter);
		datasource.close();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_ver_carro, menu);
		return true;
	}

}
